﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace StrategyAndSort
{
    class Program
    {
        static void Main(string[] args)
        {
            SortContext context;
            Console.WriteLine("待排序序列：522, 316, 55, 248, 336, 744, 121, 2, 36, 99, 13");

            Console.Write("      堆排序结果：");
            List<int> arr1 = new List<int> { 522, 316, 55, 248, 336, 744, 121, 2, 36, 99, 13 }; 
            context = new SortContext(new HeapSort());
            context.Sort<int>(arr1);
            foreach (int a in arr1) Console.Write(a + " ");
            Console.WriteLine();

            Console.Write("    希尔排序结果：");
            List<int> arr3 = new List<int> { 522, 316, 55, 248, 336, 744, 121, 2, 36, 99, 13 };
            context = new SortContext(new ShellSort());
            context.Sort<int>(arr3);
            foreach (int a in arr3) Console.Write(a+" ");
            Console.WriteLine();

            Console.Write("    快速排序结果：");
            List<int> arr2 = new List<int> { 522, 316, 55, 248, 336, 744, 121, 2, 36, 99, 13 };
            context = new SortContext(new QuickSort());
            context.Sort<int>(arr2);
            foreach (int a in arr2)  Console.Write(a + " ");
            Console.WriteLine();

            Console.Write("    归并排序结果：");
            List<int> arr4 = new List<int> { 522, 316, 55, 248, 336, 744, 121, 2, 36, 99, 13 };
            context = new SortContext(new MergeSort());
            context.Sort<int>(arr4);
            foreach (int a in arr4) Console.Write(a + " ");
            Console.WriteLine();

            Console.Write("      桶排序结果：");
            List<int> arr5 = new List<int> { 522, 316, 55, 248, 336, 744, 121, 2, 36, 99, 13 };
            context = new SortContext(new BucketSort());
            context.Sort<int>(arr5,3);
            foreach (int a in arr5) Console.Write(a + " ");
            Console.WriteLine();

            Console.Write("折半插入排序结果：");
            List<int> arr6 = new List<int> { 522, 316, 55, 248, 336, 744, 121, 2, 36, 99, 13 };
            context = new SortContext(new HalfInsertSort());
            context.Sort<int>(arr6, 3);
            foreach (int a in arr6) Console.Write(a + " ");
            Console.WriteLine();


            Console.ReadKey();
            
        }
    }
}
